package com.liuhuan.Exception;
import com.liuhuan.api.CommonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @version 1.0
 * @Author liuhuan
 * @Date 2024/7/4 21:26
 * @全局异常处理
 */






/**
 * 全局异常处理器
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public CommonResult serviceException(ServiceException e) {
        e.printStackTrace();
        return CommonResult.fail(e.getMessage());
    }
}

